﻿using System.Collections.Generic;
using System.Linq;

namespace ScrumPilot.Domain.Repositories
{
    public class SprintRepository : RepositoryBase<sprint>
    {
        public SprintRepository(DBScrumPilotEntities context)
            : base(context)
        {
        }

        public override sprint GetById(long id)
        {
            return DataContext.sprints.Include("sprintprojectiterations").First(p => p.sprintid == id);
        }

        public List<sprint> GetSprints()
        {
            return DataContext.sprints.Include("sprintprojectiterations").OrderByDescending(p => p.startdate).ThenBy(p => p.state).ToList();
        }
    }
}
